package com.unitechs.trap.excel.webapi.controller;

import com.unitechs.trap.common.pojo.trap.entity.UpdateDescr;
import com.unitechs.trap.common.pojo.trap.entity.UpdateDescrVO;
import com.unitechs.trap.common.restful.JsonResult;
import com.unitechs.trap.excel.service.IUpdateAlarmtypeService;
import com.unitechs.trap.excel.service.IUpdateTrapTypeOidService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "数据更新")
@RequestMapping("/update")
public class UpdateController {
    @Autowired
    IUpdateAlarmtypeService updateAlarmtypeService;
    @Autowired
    IUpdateTrapTypeOidService updateTrapTypeOidService;

    @GetMapping("/descr/ch")
    @ApiOperation("1、更新Descr为中文")
    public JsonResult updateDescrWithCh(){
        updateAlarmtypeService.updateDescr();
        return JsonResult.ok();
    }

    @GetMapping("/read/descr/eng")
    @ApiOperation("2、读取Descr为英文的数据")
    public JsonResult<UpdateDescrVO> listDescrWithEng(){
        UpdateDescrVO updateDescrs = updateAlarmtypeService.listEngDescr();
        return JsonResult.ok(updateDescrs);
    }

    @GetMapping("/trapoid")
    @ApiOperation("3、修改TrapType表TrapOid为.开头")
    public JsonResult updateTrapOidByTrapType(){
        updateTrapTypeOidService.updateTrapOid();
        return JsonResult.ok();
    }
    @GetMapping("/bindoid")
    @ApiOperation("4、修改VarBind表TrapOid为.开头")
    public JsonResult updateTrapOidByVarBind(){
        updateTrapTypeOidService.updateVarBindTrapOid();
        return JsonResult.ok();
    }
    @GetMapping("/delete/alarmtype")
    @ApiOperation("5、删除Alarmtype表中无效的数据")
    public JsonResult deleteAlarmtypeByCode(){
        updateTrapTypeOidService.deleteAlarmtypeByCode();
        return JsonResult.ok();
    }



}
